package com.study.a01mycollection;

import java.util.ArrayList;
import java.util.Collection;
import java.util.Iterator;

public class A04_CollectionDemo4 {
    public static void main(String[] args) {

        Collection<String> coll=new ArrayList<>();
        coll.add("hello");
        coll.add("world");
        coll.add("java");
        coll.add("hello");

        //获取迭代器
        Iterator<String> it = coll.iterator();
        //遍历集合，循环中判断是否有元素
        //遍历时不能调用集合的方法添加删除
        while (it.hasNext()){
            String s = it.next();
            System.out.println(s);
        }





    }
}
